package com.wanghua.mall.user.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.web.bind.annotation.*;

import com.wanghua.mall.user.entity.UserCollectSpuEntity;
import com.wanghua.mall.user.service.UserCollectSpuService;
import com.wanghua.common.utils.PageUtils;
import com.wanghua.common.utils.R;

import javax.annotation.Resource;



/**
 * 用户收藏的商品
 *
 * @author wanghua
 * @email 2367279431@qq.com
 * @date 2021-08-24 18:51:22
 */
@RestController
@RequestMapping("/user/usercollectspu")
public class UserCollectSpuController {

    @Resource
    private UserCollectSpuService userCollectSpuService;

    /**
     * 列表
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userCollectSpuService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		UserCollectSpuEntity userCollectSpu = userCollectSpuService.getById(id);
        return R.ok().put("userCollectSpu", userCollectSpu);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody UserCollectSpuEntity userCollectSpu){
		userCollectSpuService.save(userCollectSpu);
        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    public R update(@RequestBody UserCollectSpuEntity userCollectSpu){
		userCollectSpuService.updateById(userCollectSpu);
        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		userCollectSpuService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
